<?php
/*
	Copyright © Eleanor CMS
	URL: http://eleanor-cms.ru, http://eleanor-cms.com
	E-mail: support@eleanor-cms.ru
	Developing: Alexander Sunvas*
	Interface: Rumin Sergey
	=====
	*Pseudonym
*/
#Настройки
$url=array_keys($Eleanor->modules['sections'],'adver');
$url=reset($url);
#$url=array('russian'=>'новости','ukrainian'=>'новини','english'=>'adver',''=>'adver');#URL модуля. Может быть строкой

$limit=10;#Количество месяцев за которые брать архив
$cache=3600;#Время хранения кэша в секундах
#Конец настроек

if(is_array($url))
	$url=Eleanor::FilterLangValues($url,Language::$main);
$conf=include dirname(__file__).'/config.php';

$c=Eleanor::$Cache->Get($conf['n'].'_block_archive');
if($c===false)
{	$c=array();
	$R = Eleanor::$Db->Query('SELECT EXTRACT(YEAR_MONTH FROM IF(`pinned` IS NULL,`date`,`pinned`)) `ym`, COUNT(`id`) `cnt` FROM `'.$conf['t'].'` WHERE `status`=1 GROUP BY `q` ORDER BY `ym` DESC LIMIT '.$limit);
	while($arr=$R->fetch_assoc())
		$c[$arr['ym']]=$arr['cnt'];

	foreach($c as $k=>&$v)
	{
		$k=substr_replace($k,'-',4,0);
		$v='<a href="'.$Eleanor->Url->Construct(array('module'=>$url,array('do'=>$k)),false).'">'.Strings::UcFirst(Eleanor::$Language->Date($k,'fd')).' ('.$v.')</a>';
	}

	$c=join('<br />',$c);
	Eleanor::$Cache->Put($conf['n'].'_block_archive',$c,$cache);}return$c;
?>